package com.ruoyi.system.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ruoyi.system.domain.Recordedbroadcast;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.ProfitHistoryMapper;
import com.ruoyi.system.domain.ProfitHistory;
import com.ruoyi.system.service.IProfitHistoryService;

/**
 * 收益记录Service业务层处理
 * 
 * @author kinglu
 * @date 2021-11-30
 */
@Service
public class ProfitHistoryServiceImpl implements IProfitHistoryService 
{
    @Autowired
    private ProfitHistoryMapper profitHistoryMapper;

    /**
     * 查询收益记录
     * 
     * @param id 收益记录主键
     * @return 收益记录
     */
    @Override
    public ProfitHistory selectProfitHistoryById(Long id)
    {
        return profitHistoryMapper.selectProfitHistoryById(id);
    }

    /**
     * 查询收益记录列表
     * 
     * @param profitHistory 收益记录
     * @return 收益记录
     */
    @Override
    public List<ProfitHistory> selectProfitHistoryList(ProfitHistory profitHistory)
    {
        return profitHistoryMapper.selectProfitHistoryList(profitHistory);
    }

    /**
     * 新增收益记录
     * 
     * @param profitHistory 收益记录
     * @return 结果
     */
    @Override
    public int insertProfitHistory(ProfitHistory profitHistory)
    {
        return profitHistoryMapper.insertProfitHistory(profitHistory);
    }

    /**
     * 修改收益记录
     * 
     * @param profitHistory 收益记录
     * @return 结果
     */
    @Override
    public int updateProfitHistory(ProfitHistory profitHistory)
    {
        return profitHistoryMapper.updateProfitHistory(profitHistory);
    }

    /**
     * 批量删除收益记录
     * 
     * @param ids 需要删除的收益记录主键
     * @return 结果
     */
    @Override
    public int deleteProfitHistoryByIds(Long[] ids)
    {
        return profitHistoryMapper.deleteProfitHistoryByIds(ids);
    }

    /**
     * 删除收益记录信息
     * 
     * @param id 收益记录主键
     * @return 结果
     */
    @Override
    public int deleteProfitHistoryById(Long id)
    {
        return profitHistoryMapper.deleteProfitHistoryById(id);
    }

    /**
     *
     *通过用户编号查记录userid
     */
    public List selectRecordedbroadcastByuserId(String userid, String tag){
        Map<String, Object> map=new HashMap<String, Object>();
        List<Map<String,Object>> list = new ArrayList<>();
        if(tag.equals("1")){
            ProfitHistory profitHistory  = profitHistoryMapper.selectRecordedbroadcastByuserIdout(userid);
            map.put("getUserId",profitHistory.getGetUserId());
            map.put("giftNum",profitHistory.getGiftNum());
            map.put("giftName",profitHistory.getGiftName());
            map.put("giftTime",profitHistory.getGiftTime());
        }
        else if(tag.equals("2")){
            ProfitHistory profitHistory = profitHistoryMapper.selectRecordedbroadcastByuserIdin(userid);
            map.put("getUserId",profitHistory.getSetUserId());
            map.put("giftNum",profitHistory.getGiftNum());
            map.put("giftName",profitHistory.getGiftName());
            map.put("giftTime",profitHistory.getGiftTime());
        }
        else
            return null;
        list.add(map);
        return list;
    };

    /**
     * 获取个人收益记录
     *
     * @param profitHistory 收益记录
     * @return 收益记录集合
     */
    public List<ProfitHistory> selectProfitHistoryListUser(ProfitHistory profitHistory){
        return profitHistoryMapper.selectProfitHistoryListUser(profitHistory);
    }
}
